package com.sky.controller.user;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.sky.context.BaseContext;
import com.sky.result.Result;
import com.sky.service.UserService;
import com.sky.vo.UserProfileVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户个人信息相关接口
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserProfileController {

    @Autowired
    private UserService userService;

    /**
     * 获取用户个人信息
     *
     * @return 用户个人信息
     */
    @SaCheckLogin
    @GetMapping("/profile")
    public Result<UserProfileVO> getUserProfile() {
        log.info("获取用户个人信息");
        Integer userId = Math.toIntExact(BaseContext.getCurrentId());
        UserProfileVO userProfile = userService.getUserProfile(userId);
        return Result.success(userProfile);
    }
} 